<template>
  <div class="map-wrap">
    <!-- <mapTools></mapTools> -->
    <div id="cesiumContainer" ref="cesiumContainer"></div>
  </div>
</template>

<script>
import * as Cesium from "cesium/Cesium";
import "cesium/Widgets/widgets.css";
import mapTools from "./mapTools";
export default {
  name: "CesiumScene",
  data() {
    return {};
  },
  components: { mapTools },
  mounted() {
    this.init();
  },
  beforeDestroy() {},
  methods: {
    init() {
      let TDT_yx = new Cesium.WebMapTileServiceImageryProvider({
        url: "http://{s}.tianditu.gov.cn/img_w/wmts?tk=c233b4ecfccb56cfc41a4f51e64b33f5",
        format: "tile",
        layer: "img",
        style: "default",
        tileMatrixSetID: "w",
        credit: new Cesium.Credit("天地图影像"),
        subdomains: ["t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"],
        maximumLevel: 18,
      });

      let singleImageryLayer = new Cesium.SingleTileImageryProvider({
        url: "/static/img/earth.jpg",
      });

      let viewerOption = {
        geocoder: false, // 地理位置查询定位控件
        homeButton: false, // 默认相机位置控件
        timeline: false, // 时间滚动条控件
        navigationHelpButton: false, // 默认的相机控制提示控件
        fullscreenButton: false, // 全屏控件
        scene3DOnly: true, // 每个几何实例仅以3D渲染以节省GPU内存
        baseLayerPicker: false, // 底图切换控件
        animation: false, // 控制场景动画的播放速度控件
        // imageryProvider: TDT_yx,
        imageryProvider: singleImageryLayer,
        selectionIndicator: false,
      };
      // let viewer = new Cesium.Viewer(this.$el, viewerOption);
      let viewer = new Cesium.Viewer("cesiumContainer", viewerOption);
      viewer._cesiumWidget._creditContainer.style.display = "none"; // 隐藏版权

      window.$_baseMap3D = viewer;
    },
  },
};
</script>

<style lang="scss" scoped>
.map-wrap {
  height: 937px;
  width: 100%;
  margin: 0px;
  padding: 0px;
  overflow: hidden;
  position: relative;

  #cesiumContainer {
    width: 100%;
    height: 937px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
}
</style>
